/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ecspider;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.*;


import java.io.IOException;
import java.util.ArrayList;
import javax.swing.JPanel;
/**
 *
 * @author Mikael Köhlmyr | mikael@kohlmyr.com | http://www.kmyr.net
 */
public class spiderCanvas  extends JPanel implements MouseListener, MouseMotionListener{
    public long framecap;
    public long lastframe;
    public static final int width = Main.width;
    public static final int height = Main.height;
    public Font font = new Font("Arial", Font.BOLD, 12);
    public ArrayList<String> people = new ArrayList<String>();
    public Person adam = new Person(Main.adam);
    public spiderCanvas() {
        addMouseMotionListener(this);
        addMouseListener(this);
        this.setFocusable(true);
        framecap = 16; // 1 / FPS (60) * 1000 (Millis) = 16
        lastframe = System.currentTimeMillis();
        runtime();
    }

    public void runtime(){
        adam.setPosition(new Point(width/2, height/2));
        people.add("dem");
        //repaint();
        try {
            //String doc = spiderlib.getPageFromUrl("http://www.ecs.soton.ac.uk/people/" + Main.adam);
            people.addAll(spiderlib.spider(people));
        } catch (IOException ex) {
            System.out.println("IOException, canvas runtime made a boo boo :(((");
            //Logger.getLogger(spiderCanvas.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * Is called on repaint()
     * @param g
     */
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.setColor(Color.black);
        g.setFont(font);
        for(int i = 0; i < people.size(); i++){
            
        }
        g.drawString(people.get(0), width / 2, height / 2);
        //g.drawString(adam.ref, width/2, height/2);
    }

    public void mouseClicked(MouseEvent e) {
        System.out.println("MouseEvents not supported yet.");
    }

    public void mousePressed(MouseEvent e) {
        System.out.println("MouseEvents not supported yet.");
    }

    public void mouseReleased(MouseEvent e) {
        System.out.println("MouseEvents not supported yet.");
    }

    public void mouseDragged(MouseEvent e) {
        System.out.println("MouseEvents not supported yet.");
    }

    public void mouseEntered(MouseEvent e) {
    }

    public void mouseExited(MouseEvent e) {
    }

    public void mouseMoved(MouseEvent e) {
    }
}
